//
//  FLSShopCell.m
//  ToListenPhone
//
//  Created by zhibao on 2023/7/21.
//

#import "WatermarkCell.h"
@interface WatermarkCell(){
    UIImageView *imgView;
    UILabel *titleLabel;
    UIView *zhedangView;
}
@end

@implementation WatermarkCell
- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {

        imgView = [[UIImageView alloc] init];
        imgView.clipsToBounds = YES;
        imgView.contentMode = UIViewContentModeScaleAspectFill;
        [self.contentView addSubview:imgView];
        [imgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.contentView).offset(20);
            make.centerX.equalTo(self.contentView);
        }];
        
        zhedangView = [UIView  new];
        zhedangView.layer.cornerRadius = 15;
        [imgView addSubview:zhedangView];
        zhedangView.backgroundColor = MyColorAlpha(@"333333", 0.5);
        [zhedangView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.right.left.bottom.equalTo(imgView);
        }];
        
        UILabel *editLabel = [[UILabel alloc] init];
        editLabel.font = MY_SCALE_RegularFONT(12);
        editLabel.text = LocalizedString(@"编辑");
        editLabel.backgroundColor = MyColor(@"#12BFFF");
        editLabel.layer.masksToBounds = YES;
        editLabel.layer.cornerRadius = 13;
        editLabel.textAlignment = NSTextAlignmentCenter;
        editLabel.textColor = MyColor(@"ffffff");
        [zhedangView addSubview:editLabel];
        [editLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.mas_equalTo(60);
            make.height.mas_equalTo(26);
            make.center.equalTo(zhedangView);
        }];
        zhedangView.hidden = YES;
        
        
        
        titleLabel = [[UILabel alloc] init];
        titleLabel.font = MY_SCALE_RegularFONT(12);
        titleLabel.text = @"题目";
        titleLabel.textAlignment = NSTextAlignmentCenter;
        titleLabel.textColor = MyColor(@"333333");
        [self.contentView addSubview:titleLabel];
        [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(imgView.mas_bottom).offset(10);
            make.left.right.equalTo(imgView);
            make.bottom.equalTo(self.contentView);
        }];
    }
    return self;
}

- (void)update:(NSDictionary *)dic withFlag:(BOOL)flag{
    imgView.image = [UIImage imageNamed:dic[@"img"]];
    titleLabel.text = dic[@"title"];
    zhedangView.hidden = flag;
}


- (void)layoutSubviews {
    [super layoutSubviews];
}

@end
